package com.example.custom.autoconfigure.config;


import com.example.custom.autoconfigure.properties.CustomServiceProperties;
import com.example.custom.autoconfigure.service.CustomService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(CustomServiceProperties.class)
@ConditionalOnProperty(prefix = "custom.service", name = "enable", havingValue = "true", matchIfMissing = true)
public class CustomAutoConfiguration {

    @Bean
    public CustomService customService(CustomServiceProperties properties) {
        return new CustomService(properties);
    }
}
